var TwoSum = function() {
  this.arr = [];
};

/**
 * @param {number} number
 * @return {void}
 */
TwoSum.prototype.add = function(number) {
  this.arr.push(number);
  this.arr.sort((a, b) => a - b);
};

/**
 * @param {number} value
 * @return {boolean}
 */
TwoSum.prototype.find = function(value) {
  if(this.arr.length <= 1) return false;
  let i = 0, j = this.arr.length - 1;
  while(i < j) {
    if(this.arr[i] + this.arr[j] == value) {
      return true;
    } else if (this.arr[i] + this.arr[j] > value) {
      j--;
    } else {
      i++;
    }
  }
  return false;
};

/**
 * Your TwoSum object will be instantiated and called as such:
 * var obj = new TwoSum()
 * obj.add(number)
 * var param_2 = obj.find(value)
 */
